﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Microsoft.Samples.Kinect.WpfViewers
{
    class GFileWriter
    {
        public GFileWriter(String fileName = @"e:\log.txt", FileMode fileMode = FileMode.Append)
        {
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileName);
            fileInfo.Delete();
            fileStream = new FileStream(fileName, fileMode, FileAccess.Write);
            streamWriter = new StreamWriter(fileStream);
            streamWriter.AutoFlush = true;
        }
        ~GFileWriter()
        {
//            streamWriter.Flush();
//            fileStream.Flush();
            //streamWriter.Close();
            //fileStream.Close();
        }
        public void writeln(double x)
        {
            streamWriter.WriteLine(x);
        }
        public void writeln(GPoint pt)
        {
            this.writeln(pt.x);
            this.writeln(pt.y);
        }
        public void writeln(System.Windows.Point pt)
        {
            this.writeln(pt.X);
            this.writeln(pt.Y);
        }
        public void writeln(Microsoft.Xna.Framework.Vector3 vec)
        {
            this.writeln(vec.X);
            this.writeln(vec.Y);
            this.writeln(vec.Z);
        }
        FileStream fileStream;
        StreamWriter streamWriter;
    }
}
